<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>ComObjGet()</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>ComObjGet() <span class="ver">[AHK_L 53+]</span></h1>
<p>Returns a reference to an object provided by a COM component.</p>
<pre class="Syntax">ComObject := ComObjGet(Name)</pre>

<h3>Parameters</h3>
<dl>

  <dt>Name</dt>
  <dd><p>The display name of the object to be retrieved. See <a href="http://msdn.microsoft.com/en-us/library/ms691253.aspx">MkParseDisplayName (MSDN)</a> for more information.</p></dd>

</dl>

<h3>Related</h3>
<a href="ComObjCreate.htm">ComObjCreate</a>, <a href="ComObjActive.htm">ComObjActive</a>, <a href="ComObjConnect.htm">ComObjConnect</a>, <a href="ComObjError.htm">ComObjError</a>, <a href="ComObjQuery.htm">ComObjQuery</a>, <a href="http://msdn.microsoft.com/en-us/library/ms678805.aspx">CoGetObject (MSDN)</a>

<h3>Examples</h3>
<pre class="NoIndent" id="exwmi"><em>; Example: Press Shift+Escape to show the command line which was used
;   to launch the active window's process.  Requires XP or later.</em>
+Esc::
    WinGet pid, PID, A
    <em>; Get WMI service object.</em>
    wmi := <b>ComObjGet</b>("winmgmts:")
    <em>; Run query to retrieve matching process(es).</em>
    queryEnum := wmi.ExecQuery(""
        . "Select * from Win32_Process where ProcessId=" . pid)
        ._NewEnum()
    <em>; Get first matching process.</em>
    if queryEnum[process]
        MsgBox 0, Command line, % process.CommandLine
    else
        MsgBox Process not found!
    <em>; Free all global objects (not necessary when using local vars).</em>
    wmi := queryEnum := process := ""
return
<em>; Win32_Process: <a href="http://msdn.microsoft.com/en-us/library/aa394372.aspx">http://msdn.microsoft.com/en-us/library/aa394372.aspx</a></em>
</pre>

</body>
</html>
